# coding: utf-8

import sys
sys.path.append('../3_data_structure')
from BinaryTree import BinaryTree


def pre_order(tree):
    if tree:
        print(tree.get_root_val())
        pre_order(tree.get_left_child())
        pre_order(tree.get_right_child())


def in_order(tree):
    if tree:
        in_order(tree.get_left_child())
        print(tree.get_root_val())
        in_order(tree.get_right_child())


def post_order(tree):
    if tree:
        post_order(tree.get_left_child())
        post_order(tree.get_right_child())
        print(tree.get_root_val())


r = BinaryTree('a')
r.insert_left('b')
r.insert_right('c')

r.get_left_child().insert_left('b1')
r.get_left_child().insert_right('b2')

r.get_right_child().insert_left('c1')
r.get_right_child().insert_right('c2')

"""
       a
     /   \
    b     c
   / \   / \
  b1 b2 c1 c2
"""

pre_order(r)
print('=========================')
in_order(r)
print('=========================')
post_order(r)
